
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
      --><title>3D Model Demo</title><meta name="generator" content="MATLAB 7.12"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2011-07-20"><meta name="DC.source" content="stldemo.m"><style type="text/css">

body {
  background-color: white;
  margin:10px;
}

h1 {
  color: #990000; 
  font-size: x-large;
}

h2 {
  color: #990000;
  font-size: medium;
}

/* Make the text shrink to fit narrow windows, but not stretch too far in 
wide windows. */ 
p,h1,h2,div.content div {
  max-width: 600px;
  /* Hack for IE6 */
  width: auto !important; width: 600px;
}

pre.codeinput {
  background: #EEEEEE;
  padding: 10px;
}
@media print {
  pre.codeinput {word-wrap:break-word; width:100%;}
} 

span.keyword {color: #0000FF}
span.comment {color: #228B22}
span.string {color: #A020F0}
span.untermstring {color: #B20000}
span.syscmd {color: #B28C00}

pre.codeoutput {
  color: #666666;
  padding: 10px;
}

pre.error {
  color: red;
}

p.footer {
  text-align: right;
  font-size: xx-small;
  font-weight: lighter;
  font-style: italic;
  color: gray;
}

  </style></head><body><div class="content"><h1>3D Model Demo</h1><!--introduction--><p>This is short demo that loads and renders a 3D model of a human femur. It showcases some of MATLAB's advanced graphics features, including lighting and specular reflectance.</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Load STL mesh</a></li><li><a href="#2">Render</a></li></ul></div><h2>Load STL mesh<a name="1"></a></h2><p>Stereolithography (STL) files are a common format for storing mesh data. STL meshes are simply a collection of triangular faces. This type of model is very suitable for use with MATLAB's PATCH graphics object.</p><pre class="codeinput"><span class="comment">% Import an STL mesh, returning a PATCH-compatible face-vertex structure</span>
fv = stlread(<span class="string">'femur.stl'</span>);
</pre><h2>Render<a name="2"></a></h2><p>The model is rendered with a PATCH graphics object. We also add some dynamic lighting, and adjust the material properties to change the specular highlighting.</p><pre class="codeinput">patch(fv,<span class="string">'FaceColor'</span>,       [0.8 0.8 1.0], <span class="keyword">...</span>
         <span class="string">'EdgeColor'</span>,       <span class="string">'none'</span>,        <span class="keyword">...</span>
         <span class="string">'FaceLighting'</span>,    <span class="string">'gouraud'</span>,     <span class="keyword">...</span>
         <span class="string">'AmbientStrength'</span>, 0.15);

<span class="comment">% Add a camera light, and tone down the specular highlighting</span>
camlight(<span class="string">'headlight'</span>);
material(<span class="string">'dull'</span>);

<span class="comment">% Fix the axes scaling, and set a nice view angle</span>
axis(<span class="string">'image'</span>);
view([-135 35]);
</pre><img vspace="5" hspace="5" src="stldemo_01.png" alt=""> <p class="footer">Copyright 2011 The MathWorks, Inc.<br>
      Published with MATLAB&reg; 7.12<br></p></div><!--
##### SOURCE BEGIN #####
%% 3D Model Demo
% This is short demo that loads and renders a 3D model of a human femur. It
% showcases some of MATLAB's advanced graphics features, including lighting and
% specular reflectance.

% Copyright 2011 The MathWorks, Inc.


%% Load STL mesh
% Stereolithography (STL) files are a common format for storing mesh data. STL
% meshes are simply a collection of triangular faces. This type of model is very
% suitable for use with MATLAB's PATCH graphics object.

% Import an STL mesh, returning a PATCH-compatible face-vertex structure
fv = stlread('femur.stl');


%% Render
% The model is rendered with a PATCH graphics object. We also add some dynamic
% lighting, and adjust the material properties to change the specular
% highlighting.

patch(fv,'FaceColor',       [0.8 0.8 1.0], ...
         'EdgeColor',       'none',        ...
         'FaceLighting',    'gouraud',     ...
         'AmbientStrength', 0.15);

% Add a camera light, and tone down the specular highlighting
camlight('headlight');
material('dull');

% Fix the axes scaling, and set a nice view angle
axis('image');
view([-135 35]);
##### SOURCE END #####
--></body></html>